$(function(){
        $('[name=old_pwd]').focus();
        $('[name=b]').click(function(){
            var old_pwd=$('[name=old_pwd]').val();
            var new_pwd=$('[name=new_pwd]').val();
            var new_pwd1=$('[name=new_pwd1]').val();
            if(check(old_pwd,new_pwd,new_pwd1)){
                $.post(app_url+"/userconfig-save_editpwd",{
                    'old_pwd':old_pwd,
                    'new_pwd':new_pwd
                },function(data){chuli(data.data)},'json');
            }
        });

        function chuli(data){
            switch(data){
                case 0:
                    $("#pop").html('原密码不正确，请重新输入原密码！');
                    $('[name=old_pwd]').val('');
                    $('[name=old_pwd]').focus();
                    break;
                case 1:
                    $("#pop").html('新密码修改成功，请牢记您的新密码！');
                    $('[name=old_pwd]').val('');
                    $('[name=new_pwd]').val('');
                    $('[name=new_pwd1]').val('');
                    $('[name=old_pwd]').focus();
                    break;
                case 2:
                    $("#pop").html('本次密码未修改成功，可能原因为原密码与新密码相同或者为系统错误！');
                    $('[name=old_pwd]').val('');
                    $('[name=new_pwd]').val('');
                    $('[name=new_pwd1]').val('');
                    $('[name=old_pwd]').focus();
                    break;
            }
        }


        function check(old_pwd,new_pwd,new_pwd1){

            if(old_pwd==''){
                $('#old_pwd').html('原密码不能为空！请填写原密码！');
                $('[name=old_pwd]').focus();
                return false;
            }
            if(new_pwd==''){
                $('#new_pwd').html('新密码不能为空！请填写新密码！');
                $('[name=new_pwd]').focus();
                return false;
            }
            if(new_pwd!=new_pwd1){
                $('#new_pwd').html('新密码两次输入不一致，请重新填写新密码！');
                $('[name=new_pwd]').val('');
                $('[name=new_pwd1]').val('');
                $('[name=new_pwd]').focus();
                return false;
            }
            return true;
        }

        $("#pop").ajaxStart(function(){
            $("#pop").html('<img src="'+base_url+'/images/loading.gif" />数据获取中，请稍后...');
        });

    });